package com.wm.singleton;

/**
 * @ClassName: Singleton_05
 * @Description: 双重校验锁（线程安全）
 * @Author: WM
 * @Date: 2022/12/20 12:27
 */
public class Singleton_05 {

    private static volatile Singleton_05 instance; // 对象锁

    private Singleton_05() {

    }

    public static Singleton_05 getInstance() {
        if (instance != null) {
            return instance;
        }
        synchronized (Singleton_05.class) {// synchronized方法锁
            if (instance == null) {
                instance = new Singleton_05();
            }
        }
        return instance;
    }
}
